package com.wjw.java.others.date_;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Date_ {
    public static void main(String[] args) throws ParseException {
        //1.Date日期转为格式化后的字符串
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//2022-08-01 23:59:59
        String formatDate = sdf.format(date);
        System.out.println(formatDate);

        //2.格式化后的字符串转为Date日期
        Date parseDate = sdf.parse("2022-08-01 23:59:59");
        System.out.println(parseDate);

    }
}
